#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    
    //创建单个内存
    int * val_1 = new int ;
    *val_1 = 10 ;
    cout << "val_1 = " << *val_1 << endl;

    //创建单个内存 并 初始化 可以直接在括号内写值 也可以直接在括号内写 变量
    int *val_2 = new int(15);
    cout << "val_2 = "<< *val_2 << endl;

    int *val_3 = new int(*val_2);
    cout<< "val_3 = " << *val_3 << endl;

    //创建多个内存
    int * arr = new int[5];

    for (size_t i = 0; i < 5; i++)
    {
        arr[i] = i;
        cout << "arr = " << arr[i] << endl;
    }
    
    //回收内存
    delete val_1;
    delete val_2;
    delete val_3;
    delete [] arr;
    
    return 0;
}
